package com.lire.shop.dao;

import com.lire.shop.entity.Product;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

@Repository
@Transactional
public interface ProductRepository extends JpaRepository<Product, Long> {
    @Modifying
    @Query("update shop_product  set stock=:stock where  pid=:pid")
    void updateStockByPid(
            @Param("stock") Integer stock,
            @Param("pid") Long pid);
}
